<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
class Product_model extends CI_Model {
	public function __construct() {
		parent::__construct ();
	}
	/*
	 * 得到上架的商品信息(用于一键操作)
	 */
	public function find_products(){
		$this->db->where("show", 1);
		$this->db->where("sale", 0);
		$this->db->order_by("categoryid", "asc");
		$this->db->order_by("varietyid", "asc");		
		$query=$this->db->get('t_product');		
		return $query->result_array();
	}
	/*
	 * 返回蔬菜类商品
	 */
	public function find_green_products(){
		$this->db->where("show", 1);
		$this->db->where("sale", 0);
		$this->db->where("categoryid", 13);
		$this->db->order_by("varietyid", "asc");		
		$query=$this->db->get('t_product');		
		return $query->result_array();
	}
	/*
	 * 根据商品名称返回上架商品的信息
	 */
	public function get_show_product_by_name($name){
		$this->db->select('id,name,description,price,purprice,unit');
		$this->db->where("show", 1);
		$this->db->where("sale", 0);
		$this->db->like('name', $name);
		$query=$this->db->get('t_product');
		return $query->result_array();
	}
}